﻿
using System.Collections.Generic;
using System.Data;
using System;
namespace ZHDJ.MobileInterface
{
    public partial class GetInformationDetail : AbstractBasePage
    {
        protected override OutParam BusinessProcess<InParam, OutParam>(InParam inParam)
        {
            // 业务逻辑返回的响应对象  
            InformationDetailOutParam result = new InformationDetailOutParam();
            InformationDetailInParam param = new InformationDetailInParam();
            string logMsg = "";
            bool isFlag = true;
                 
            try
            {
                param = inParam as InformationDetailInParam;
                if (string.IsNullOrEmpty(param.msg_id))
                {
                    result.code = "0";
                    result.desc = "资讯ID不能为空";

                    isFlag = false;
                }

                //if (param.type != "1" && param.type != "2" && param.type != "3" && param.type != "4" && param.type != "5" && param.type != "6" && param.type != "7")
                if (param.type != "1" && param.type != "4" && param.type != "6" && param.type != "7")
                {
                    result.code = "0";
                    //result.desc = "类别只能为1(通知公告),或2(热点新闻),或3(学习十八大),或4(党员先锋),或5(组织风采),或6(干部工作),或7(人才天地)";
                    result.desc = "类别只能为1(通知公告),或4(党员先锋),或6(干部工作),或7(人才天地)";

                    isFlag = false;
                }

                if(isFlag)
                {
                    result.data.content_url = CommonUtils.AppAddressEx + "html/InformationDetail.aspx?InfoType=" + param.type + "&InfoID=" + param.msg_id; 
                }
                logMsg = result.desc;
            }
            catch (Exception ex)
            {
                result.code = "0";
                result.desc = "操作异常，多次出现请联系管理员"; 
                logMsg = ex.Message + ":" + ex.StackTrace;
            }

            CommonUtils.InsertMobileInterfaceLog(SystemCode +"-GetInformationDetailList", SerializeHelper.JsonSerializer<InformationDetailInParam>(param), logMsg); 
            return result as OutParam;
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (string.Compare(Request.QueryString["Safe"], "False", true) == 0)
                ProcessRequest<InformationDetailInParam, InformationDetailOutParam>();
            else
                SafeProcessRequest<InformationDetailInParam, InformationDetailOutParam>();
        }
    }

    #region 请求参数
    public class InformationDetailInParam
    {
        /// <summary>
        /// 必填，1：通知公告，2：热点新闻，3：学习十八大， 4：党员先锋
        /// </summary>
        public string type
        { get; set; }

        /// <summary>
        /// 必填	资讯ID
        /// </summary>
        public string msg_id
        { get; set; } 
    }
    #endregion

    #region 结果参数
    public class InformationDetailOutParam
    {
        public InformationDetailOutParam()
        {
            code = "1";
            desc = "操作成功";
            data = new InformationDetail();
        }

        /// <summary>
        /// 返回结果 具体见接口返回对照码 1	成功 0	失败 2	请求非法 加密结果和传入的MD5字符串进行比较，如果相同则执行接口操作，否则返回1001错误响应码
        /// </summary>
        public string code
        { get; set; }

        /// <summary>
        /// 结果描述 成功和失败都需要
        /// </summary>
        public string desc
        { get; set; }

        /// <summary>
        /// 资讯详情
        /// </summary>
        public InformationDetail data
        { get; set; }
    } 
     
    /// <summary>
    /// 资讯详情
    /// </summary>
    public class InformationDetail
    {
        /// <summary>
        ///	资讯详情HTML页面地址
        /// </summary>
        public string content_url
        { get; set; } 
    }
    #endregion 
}